
import { request } from 'umi';
import { GetUserListRequestParams, GetUserDetailsRequestParams, GetUserDetailsResponse,UserDeleteRequestParams,UserInfoSaveRequestParams} from './data.d';
//查询用户列表
export async function queryUserList(
    body:GetUserListRequestParams,
    options?: { [key: string]: any }){
    const { pageNo,pageSize,officeId,keywords} = body;
    return request(
        `/aircaskb/sys/user/findList?pageNo=${pageNo}&pageSize=${pageSize}&officeId=${officeId}&keywords=${keywords}`,
        {   
            headers: {
                'Content-Type': 'application/x-www-form-urlencoded',
            },
            method: 'GET',
            ...(options || {}),
        },
    );
}
// 获取用户详情
export async function GetUserDetailsRequest(
    body: GetUserDetailsRequestParams, 
    options?: { [key: string]: any }){
    const { userId } = body;
    return request<AircasKB.ResponseType<GetUserDetailsResponse>>(
        `/aircaskb/sys/user/getUserInfo/${userId}`,
        {   
            headers: {
                'Content-Type': 'application/x-www-form-urlencoded',
            },
            method: 'GET',
            ...(options || {}),
        },
    );
}
// 保存用户信息
export async function UserInfoSaveRequest(body:UserInfoSaveRequestParams, options?: {[key: string]: any}){
    return request(
        `/aircaskb/sys/user/save`, {
            method: 'POST',
            data:body,
            ...(options || {}),
        });
}

// 删除用户
export async function DeleteUserRequest(
    body: UserDeleteRequestParams, 
    options?: { [key: string]: any }){
    const { ids } = body;
    return request<AircasKB.ResponseType<GetUserDetailsResponse>>(
        `/aircaskb/sys/user/delete/${ids}`,
        {   
            headers: {
                'Content-Type': 'application/x-www-form-urlencoded',
            },
            method: 'GET',
            ...(options || {}),
        },
    );
}